<%inherit file="../base.html" />
<%! from django.urls import reverse %>
<%def name="content()">
    <div class="edit-area" style="width: 400px;margin: 80px auto;border: 1px solid #cccccc">
        <div class="form-group" style="margin-left: 10%;margin-top: 10%">
        <label>修改电影信息</label>
        </div>
        <div class="form-group" style="margin-left: 10%;margin-top: 10%">
        <label>Title：</label>
        <input type="text" name="Title" class="form-control" id="Title" placeholder="Title" style="width: 200px">
        </div>
        <div class="form-group" style="margin-left: 10%;margin-top: 10%">
        <label>New Title：</label>
        <input type="text" name="New_Title" class="form-control" id="New_Title" placeholder="New Title" style="width: 200px">
        </div>
        <div class="form-group" style="margin-left: 10%;margin-top: 5%">
            <label>Genres：</label><br/>
            <input name="Genres" type="checkbox" value="Adventure"/>Adventure
            <input name="Genres" type="checkbox" value="Animation"/>Animation
            <input name="Genres" type="checkbox" value="Children"/>Children
            <input name="Genres" type="checkbox" value="Comedy"/>Comedy<br/>
            <input name="Genres" type="checkbox" value="Fantasy"/>Fantasy
            <input name="Genres" type="checkbox" value="Drama"/>Drama
            <input name="Genres" type="checkbox" value="Romance"/>Romance
            <input name="Genres" type="checkbox" value="Action"/>Action<br/>
            <input name="Genres" type="checkbox" value="Thriller"/>Thriller
            <input name="Genres" type="checkbox" value="Horror"/>Horror
            <input name="Genres" type="checkbox" value="Crime"/>Crime
            <input name="Genres" type="checkbox" value="Mystery"/>Mystery<br/>
            <input name="Genres" type="checkbox" value="Sci-Fi"/>Sci-Fi
            <input name="Genres" type="checkbox" value="War"/>War
            <input name="Genres" type="checkbox" value="Musical"/>Musical
            <input name="Genres" type="checkbox" value="Documentary"/>Documentary<br/>
            <input name="Genres" type="checkbox" value="Film-Noir"/>Film-Noir
            <input name="Genres" type="checkbox" value="Western"/>Western<br/>
            <input type="submit" class="btn btn-info sub" style="margin-top: 15px"/>
        </div>
    </div>
</%def>

<%def name="js()">
    <script>
        $(".sub").click(function () {
            var url = '${reverse('modify')}';
            var title = $("#Title").val();
            var new_title = $("#New_Title").val();
            var genres_list = new Array();

            $("input[name='Genres']:checked").each(function () {
                genres_list.push($(this).val());
            });

             $.ajax({
                 traditional:true,
                 url: url,
                 type: 'post',
                 data: {
                     title: title,
                     new_title: new_title,
                     genres_list: genres_list
                 },
                 success: function (data) {
                     alert(data.msg);
                     window.location.reload()
                 }
             })
        })
    </script>
</%def>